---------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\sbstjp\OneDrive - Cardiff University\FinalHarvard\Appendix3.4.log
  log type:  text
 opened on:  12 May 2025, 17:57:01

. use "C:\Users\sbstjp\OneDrive - Cardiff University\PVScleandata.dta" // Prosser, Magasin, Proulx and Haddock,
>  UK Progressive Values Dataset, April 2024 // Accessed on March 16 2025

. 
. // Create a weight
. gen weight = 1

. 
. * Code variables into categories
. recode age (min/24=1 "0-24") (25/34=2 "25-34") (35/44=3 "35-44") (45/54=4 "45-54") (55/max=5 "55+"), generate
> (age_group)
(672 differences between age and age_group)

. recode ethnicity (1=1) (2=2) (3=3) (5=4) (6=4) (7=4) (4=5) (8=6), generate(ethnic_group)
(243 differences between ethnicity and ethnic_group)

. label define ethnic_group_lbl 1 "White" 2 "Black" 3 "Hispanic" 4 "Asian or Native Hawaiian/other Pacific Isla
> nder, non-Hispanic" 5 "Native American/Alaska Native or other race, non-Hispanic" 6 "Multiple races, non-Hisp
> anic"

. label values ethnic_group ethnic_group_lbl

. recode education (3=1) (4=1) (5=1) (6=2) (7=2) (8=3) (9=4) (10=4) (11=4), generate(ed_group)
(672 differences between education and ed_group)

. recode householdincome (1=1) (2=1) (3=1) (4=1) (5=1) (6=1) (7=1) (8=2) (9=2) (10=2) (11=2) (12=3) (13=4), gen
> erate(inc_group)
(621 differences between householdincome and inc_group)

. 
. * Generate totals for the weights - these are based on the ANES24 pre-election wave as this dataset has polit
> ical selfid, unlike census data. The below are for 1-4, i.e. very liberal to centrist, on the political selfi
> d scale. This mirrors the PVS sample. 
. replace gender=. if inrange(gender, 3, 5)
(34 real changes made, 34 to missing)

. rename gender FemaleGender

. gen sextot=.
(672 missing values generated)

. replace sextot = 0.4663 if FemaleGender == 1 // Male
(211 real changes made)

. replace sextot = 0.5337 if FemaleGender == 2 // Female
(427 real changes made)

. 
. gen agetot=.
(672 missing values generated)

. replace agetot = 0.1227 if age_group == 1 //18-24
(110 real changes made)

. replace agetot = 0.1848 if age_group == 2 //25-34
(218 real changes made)

. replace agetot = 0.1891 if age_group == 3 //35-44
(160 real changes made)

. replace agetot = 0.1544 if age_group == 4 //45-54
(111 real changes made)

. replace agetot = 0.3491 if age_group == 5 //55+
(73 real changes made)

. 
. gen ethtot=. 
(672 missing values generated)

. replace ethtot = 0.6038 if ethnic_group == 1 // White
(154 real changes made)

. replace ethtot = 0.1186 if ethnic_group == 2 // Black
(153 real changes made)

. replace ethtot = 0.1592 if ethnic_group == 3 // Hispanic
(121 real changes made)

. replace ethtot = 0.0659 if ethnic_group == 4 // Asian or Native Hawaiian
(150 real changes made)

. replace ethtot = 0.0024 if ethnic_group == 5 // Native American
(19 real changes made)

. replace ethtot = 0.0502 if ethnic_group == 6 // Multiple
(74 real changes made)

. 
. gen edtot=.
(672 missing values generated)

. replace edtot = 0.4408 if ed_group == 1 // Uptosomecollege
(219 real changes made)

. replace edtot = 0.0926 if ed_group == 2 // Trade/assocdegree
(90 real changes made)

. replace edtot = 0.2754 if ed_group == 3 // Undergraddegree
(253 real changes made)

. replace edtot = 0.1912 if ed_group == 4 // Postgradandabove
(110 real changes made)

. 
. gen inctot=.
(672 missing values generated)

. replace inctot = 0.2528 if inc_group == 1 //under 60k
(352 real changes made)

. replace inctot = 0.2084 if inc_group  == 2 //60-100k
(190 real changes made)

. replace inctot = 0.1966 if inc_group  == 3 //100-150k
(76 real changes made)

. replace inctot = 0.3422 if inc_group  == 4 //over 150k
(54 real changes made)

. 
. * Rake the weights using the Stata survwgt package
. survwgt rake weight , by(FemaleGender age_group ethnic_group ed_group inc_group) totvars(sextot agetot ethtot
>  edtot inctot) generate(rakedweight)

. 
. // Demographics
. *Create dummies
. 
. gen ReligiousAtt=.
(672 missing values generated)

. replace ReligiousAtt=1 if religiousattendance==7
(74 real changes made)

. replace ReligiousAtt=0 if inlist(religiousattendance, 1, 2, 3, 4, 5, 6, 9)
(582 real changes made)

. 
. gen Graduate=. 
(672 missing values generated)

. replace Graduate=0 if inrange(education, 3, 7)
(309 real changes made)

. replace Graduate=1 if inrange(education, 8, 11)
(363 real changes made)

. 
. gen Married=.
(672 missing values generated)

. replace Married=1 if inlist(maritalstatus, 1, 2)
(203 real changes made)

. replace Married=0 if inrange(maritalstatus, 3, 8)
(469 real changes made)

. 
. gen Unemployed=. 
(672 missing values generated)

. replace Unemployed=0 if inlist(employment, 1, 2)
(485 real changes made)

. replace Unemployed=1 if employment==3
(105 real changes made)

. 
. egen age_centered = mean(age) 

. replace age_centered = age - age_centered
(672 real changes made)

. gen age_centered_squared = age_centered^2

. 
. // Life Satisfaction
. *Reverse so satisfaction coded high
. foreach var in lifesatisfaction {
  2.     qui sum `var'
  3.     local max_value = r(max)
  4.     gen R`var' = `max_value' - `var'
  5. }

. 
. *Standardize from 1-2, so it's like other dependent variables in the book
. foreach var in Rlifesatisfaction {
  2.     summarize `var'
  3.     gen s`var' = 1 + (`var' - r(min)) / (r(max) - r(min))
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
Rlifesatis~n |        672     1.71131    1.082302          0          4

. 
. rename sRlifesatisfaction LifeSat

. 
. // Standardize variables 
. egen Age = std(age_centered_squared) 

. egen Income = std(householdincome)

. egen PVS = std(pvs)

. 
. // Regressions
. regress LifeSat PVS [pweight=rakedweight], robust 
(sum of wgt is 1)

Linear regression                               Number of obs     =        637
                                                F(1, 635)         =       0.83
                                                Prob > F          =     0.3626
                                                R-squared         =     0.0068
                                                Root MSE          =     .27873

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         PVS |   .0237796    .026101     0.91   0.363    -.0274751    .0750344
       _cons |   1.519744   .0280198    54.24   0.000     1.464721    1.574766
------------------------------------------------------------------------------

. eststo
(est1 stored)

. regress LifeSat PVS Age FemaleGender Graduate Income Married ReligiousAtt [pweight=rakedweight], robust 
(sum of wgt is .9883845622985099)

Linear regression                               Number of obs     =        623
                                                F(7, 615)         =      14.62
                                                Prob > F          =     0.0000
                                                R-squared         =     0.2695
                                                Root MSE          =     .24038

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         PVS |   .0416428   .0184885     2.25   0.025     .0053345    .0779511
         Age |   .0309839   .0120932     2.56   0.011     .0072349     .054733
FemaleGender |   .0339985   .0606941     0.56   0.576    -.0851944    .1531913
    Graduate |   .1284555   .0673196     1.91   0.057    -.0037487    .2606597
      Income |   .0909145   .0230196     3.95   0.000      .045708    .1361211
     Married |   .0509716   .0505202     1.01   0.313    -.0482413    .1501846
ReligiousAtt |   .0300047   .0553856     0.54   0.588    -.0787632    .1387726
       _cons |   1.306455   .1163452    11.23   0.000     1.077973    1.534937
------------------------------------------------------------------------------

. eststo
(est2 stored)

. regress LifeSat PVS Age FemaleGender Graduate Income Married ReligiousAtt Unemployed [pweight=rakedweight], r
> obust 
(sum of wgt is .8424930971366592)

Linear regression                               Number of obs     =        547
                                                F(8, 538)         =      14.76
                                                Prob > F          =     0.0000
                                                R-squared         =     0.3108
                                                Root MSE          =     .23945

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         PVS |   .0413773    .020293     2.04   0.042     .0015141    .0812405
         Age |   .0387165   .0168039     2.30   0.022     .0057072    .0717257
FemaleGender |   .0468147   .0590223     0.79   0.428    -.0691278    .1627571
    Graduate |   .1551067   .0745935     2.08   0.038     .0085766    .3016369
      Income |   .0591153    .027552     2.15   0.032     .0049925     .113238
     Married |   .0690924   .0517765     1.33   0.183    -.0326165    .1708014
ReligiousAtt |    .009751   .0673367     0.14   0.885     -.122524    .1420261
  Unemployed |  -.1904286   .0622794    -3.06   0.002    -.3127692    -.068088
       _cons |   1.299598   .1156918    11.23   0.000     1.072335    1.526861
------------------------------------------------------------------------------

. eststo
(est3 stored)

. esttab

------------------------------------------------------------
                      (1)             (2)             (3)   
                  LifeSat         LifeSat         LifeSat   
------------------------------------------------------------
PVS                0.0238          0.0416*         0.0414*  
                   (0.91)          (2.25)          (2.04)   

Age                                0.0310*         0.0387*  
                                   (2.56)          (2.30)   

FemaleGender                       0.0340          0.0468   
                                   (0.56)          (0.79)   

Graduate                            0.128           0.155*  
                                   (1.91)          (2.08)   

Income                             0.0909***       0.0591*  
                                   (3.95)          (2.15)   

Married                            0.0510          0.0691   
                                   (1.01)          (1.33)   

ReligiousAtt                       0.0300         0.00975   
                                   (0.54)          (0.14)   

Unemployed                                         -0.190** 
                                                  (-3.06)   

_cons               1.520***        1.306***        1.300***
                  (54.24)         (11.23)         (11.23)   
------------------------------------------------------------
N                     637             623             547   
------------------------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. 
. log close
      name:  <unnamed>
       log:  C:\Users\sbstjp\OneDrive - Cardiff University\FinalHarvard\Appendix3.4.log
  log type:  text
 closed on:  12 May 2025, 17:57:14
---------------------------------------------------------------------------------------------------------------
